-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Stripe] Implement Refund event listener in Stripe webhook #556
Conversation
✅ Tests will run for this PR. Once they succeed it can be merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all great!
the logic is implemented on the right places and I especially like how you made the refactoring around Increment/Decrement to preserve readability and correctness.
my only request for change is the text in the email as per the comment
Транзакцията ще отнеме от 5 до 10 дни и парите ви ще бъдат върнати по същия начин, по | ||
който са били получени. <br /><br /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
нека да променим текста за да е малко по-ясно:
"парите ще ви бъдат върнати към същата карта, с която сте превели дарението към Страйп."
/** | ||
* Refund a stipe payment donation | ||
* https://stripe.com/docs/api/refunds/create | ||
* @param inputDto Refund-stripe params | ||
* @returns {Promise<Stripe.Response<Stripe.Refund>>} | ||
*/ | ||
async refundStripePayment(paymentIntentId: string): Promise<Stripe.Response<Stripe.Refund>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great for including the reference to the docs!
|
||
return await this.stripeClient.refunds.create({ | ||
payment_intent: paymentIntentId, | ||
reason: 'requested_by_customer', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[TODO] for next version, it would be good to allow several predefined reasons and a free text that can be selected/entered on the fronted from the Admin UI.
I will write a separate ticket for this
await this.sendEmail.sendFromTemplate(mail, recepient, { | ||
//Allow users to receive the mail, regardles of unsubscribes | ||
bypassUnsubscribeManagement: { enable: true }, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call here!
This PR ensures we will handle stripe refund event, so that in case of Refund request, the refunded amounts to be properly substracted.
The refund itself is by calling /api/v1/donation/refund-stripe-paymet/ endpoint or from billing Stripe Admin UI. After refund request is received Stripe sends a charge.refunded event: https://stripe.com/docs/api/refunds/object
After we receive this event, we will:
Relates to podkrepi-bg/frontend#1635
Closes #518 and podkrepi-bg/frontend#1585
Test:
Created a donation:
After refund button is clicked - donation is not present in the campaign tab:
End user will receive the following mail: